package com.yoo.ons.adapter

import android.app.Activity
import android.graphics.Color
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import com.yoo.module_base.utils.setOnClickCallback
import com.yoo.ons.R
import com.yoo.ons.base.adpater.BaseRecyclerAdapter
import com.yoo.ons.databinding.ItemUpdateUserInfoBinding
import com.yoo.ons.model.UserWantOrYouAcceptModel

class UpdateUserInfoAdapter(var activity: Activity, var callback: (position: Int) -> Unit) :
    BaseRecyclerAdapter<UserWantOrYouAcceptModel, ItemUpdateUserInfoBinding>(
        ItemUpdateUserInfoBinding::inflate
    ) {
    override fun onBindView(
        holder: VH<ItemUpdateUserInfoBinding>,
        position: Int,
        item: UserWantOrYouAcceptModel?
    ) {
        holder.binding.itemText.text = item?.value
        holder.binding.itemText.setTextColor(if (item?.selected == 1) ContextCompat.getColor(activity, com.yoo.module_res.R.color.color_E2449D) else Color.WHITE)
        holder.binding.itemCheckLogo.isVisible = item?.selected == 1
        holder.binding.itemContainer.setBackgroundResource(if (item?.selected == 1) com.yoo.module_res.R.drawable.shape_update_info_bg else com.yoo.module_res.R.drawable.shape_solid_771b96_radius_26)
        holder.binding.itemContainer.setOnClickCallback {
            callback.invoke(position)
        }
    }
}